// 引入主题变量
@import '@devui/theme/styles-var/devui-var.scss';

.#{$devui-prefix}-editable-select {
  &-input {
    height: 32px;
    font-size: $devui-font-size;

    &--sm {
      height: $devui-size-sm;
      font-size: $devui-font-size-sm;
    }

    &--lg {
      height: $devui-size-lg;
      font-size: $devui-font-size-lg;
    }

    &--open {
      .#{$devui-prefix}-editable-select__arrow-icon {
        transform: rotate(180deg);
      }
    }

    &__wrapper {
      display: flex;
      align-items: center;
      justify-content: center;
      position: relative;
      height: 100%;
      padding: 0 8px;
      border: 1px solid $devui-form-control-line;
      border-radius: $devui-border-radius;
      background-color: $devui-form-control-bg;
      transition: border-color 0.3s $devui-animation-ease-in-out-smooth;

      &:not(.#{$devui-prefix}-editable-select-input__wrapper--disabled):not(&--focus):hover {
        border-color: $devui-form-control-line-hover;
      }

      &--focus {
        border-color: $devui-form-control-line-active;
      }

      &--disabled {
        color: $devui-disabled-text;
        border-color: $devui-disabled-line;
        background-color: $devui-disabled-bg;
        cursor: not-allowed;

        &:hover {
          border-color: $devui-disabled-line;
        }

        .#{$devui-prefix}-editable-select-input__inner {
          color: $devui-disabled-text;
          cursor: not-allowed;
        }
      }
    }

    &__inner {
      width: 100%;
      height: 100%;
      padding: 4px 0;
      border: none;
      background: none;
      outline: none;
    }

    &__placeholder {
      width: calc(100% - 16px);
      position: absolute;
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
      transform: translateY(-50%);
      top: 50%;
    }

    &__suffix {
      height: 100%;
      display: inline-flex;
      align-items: center;
      justify-content: center;
      font-size: $devui-font-size;

      & > span {
        align-items: center;
      }

      .#{$devui-prefix}-editable-select__clear-icon {
        pointer-events: auto;
        display: flex;
        cursor: pointer;
      }

      .#{$devui-prefix}-editable-select__arrow-icon {
        display: flex;
        transition: transform $devui-animation-duration-slow $devui-animation-ease-in-out-smooth;
      }
    }
  }

  &__dropdown {
    margin: 8px 0;
  }

  &__inner {
    padding: 12px;
    margin: 0;
    list-style: none;
    overflow-y: auto;
  }

  &__item {
    cursor: pointer;
    user-select: none;
    line-height: 20px;
    padding: 8px 12px;
    border: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;

    &:not(:first-child) {
      margin-top: 4px;
    }

    &--disabled {
      cursor: not-allowed;
      color: $devui-disabled-text;
    }

    &--selected:not(&--disabled):not(&--no-data-tip) {
      color: $devui-list-item-active-text;
      background-color: $devui-list-item-active-bg;
    }

    &--last-selected {
      background: $devui-list-item-hover-bg;
      color: $devui-list-item-hover-text;
    }

    &--hover:not(&--selected) {
      background-color: $devui-list-item-hover-bg;
      color: $devui-list-item-hover-text;
    }

    &:not(&--disabled):not(&--selected):not(&--no-data-tip):hover {
      background-color: $devui-list-item-hover-bg;
      color: $devui-list-item-hover-text;
    }

    &--no-data-tip {
      text-align: center;
      cursor: not-allowed;
      user-select: none;
      color: $devui-disabled-text;
      font-size: $devui-font-size;
      line-height: 22px;
      padding: 0;
    }
  }
}
